<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en" xmlns="http://www.w3.org/1999/xhtml" 
      xmlns:h="http://java.sun.com/jsf/html" 
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui">
<body>
 <ui:composition template="/templates/Plantilla.xhtml">	
  <ui:define name="content">
	<h:form class="form">
	<p:messages />
	<h3> Crear Nuevo Reparto</h3>
	<p:separator />
	<p:panel>
		<h:panelGrid columns="2">
		
			<h:outputText value="Nombre: *" style = "font-weight: bold;"/>
			<p:inputText value="#{repartoCreate.reparto.nombre}"
				required="true" label ="Nombre"/>
			
			<h:outputText value="Repartidor Responsable: *" style = "font-weight: bold;"/>
			<p:selectOneMenu value="#{repartoCreate.reparto.repartidor.personalId}" 
				label="Categorias" required = "true">
				<f:selectItems value="#{repartoCreate.repartidoresDisponibles}" 
							var="personal" 
							itemLabel="#{personal.apellido} #{personal.nombre}" 
							itemValue="#{personal.personalId}"/>
			</p:selectOneMenu>			
			
			<h:outputText value="Vehiculo: *" style = "font-weight: bold;"/>
			<p:selectOneMenu value="#{repartoCreate.reparto.vehiculo.vehiculoId}" 
				label="Vehiculo" required = "true">
				<f:selectItems value="#{repartoCreate.vehiculosDisponibles}" 
						var="vehiculo"
						itemLabel ="#{vehiculo.patente}"
						itemValue = "#{vehiculo.vehiculoId}"/>
			</p:selectOneMenu>
			
		    <h:outputText value="Descripcion:" style = "font-weight: bold;"/>
			<p:inputText value="#{repartoCreate.reparto.descripcion}"/>

		</h:panelGrid>
	</p:panel>
	
	<p:panel>
		<p:commandButton value="Guardar" action="#{repartoCreate.crearReparto(repartoCreate.reparto)}" ajax="false"
			icon="ui-icon-disk"></p:commandButton>
		<p:commandButton value="Cancelar" action="#{repartoCreate.cancelarAlta}" ajax="false" immediate="true"
			icon="ui-icon-close"></p:commandButton>	
	</p:panel>		
	</h:form>			
  </ui:define>
 </ui:composition>	
</body>
</html>